package studyStream;

import java.util.*;
import java.util.stream.Collectors;

public class EndWayStream {
    public static void main(String[] args) {
        ArrayList<String> list2 = new ArrayList<>();
        Collections.addAll(list2, "徐瑞琪-21", "徐添琪-21", "徐锦慧-21", "徐锦媛-21", "徐烨-21");
        //forEach遍历
        list2.stream().forEach(s -> System.out.println(s));
        System.out.println("===============");
        //统计
        System.out.println(list2.stream().count());
        System.out.println("===============");
        //存入数组
        String[] people = list2.stream().toArray(value -> new String[value]);
        System.out.println(Arrays.toString(people));
        System.out.println("===============");
        //存入集合list
        List<String> strings = list2.stream().collect(Collectors.toList());
        System.out.println(strings);
        System.out.println("===============");
        //存入set集合
        Set<String> collect = list2.stream().collect(Collectors.toSet());
        System.out.println(collect);
        System.out.println("===============");
        //存入map集合
        Map<String, String> collect1 = list2.stream().collect(Collectors.toMap(
                s -> s.split("-")[0],
                s -> s.split("-")[1]));
        System.out.println(collect1);


    }
}
